package com.catmiao.rdd.instance;

import com.alibaba.fastjson.JSONObject;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.api.java.function.FlatMapFunction;
import scala.Tuple9;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author ChengMiao
 * @title: Test
 * @projectName spark_study
 * @description: TODO
 * @date 2024/8/8 09:54
 */
public class Test {
    public static void main(String[] args) {


        String str = "\\\"年、月、日 \\\"";
        str = str.replace("\\\"", "");
        String[] split = str.trim().split(" ");
        System.out.println(split);


//
//        SparkConf sparkConf = new SparkConf();
//        sparkConf.setMaster("local");
//        sparkConf.setAppName("env01");
//
//        JavaSparkContext javaSparkConf = new JavaSparkContext(sparkConf);
//
//
//        // 数据源
//
//        JavaRDD<String> rdd = javaSparkConf.textFile("datas/exam/主观题1.txt");
//
//        JavaRDD<Tuple9> rddResult = rdd.flatMap(new FlatMapFunction<String, Tuple9>() {
//            @Override
//            public Iterator<Tuple9> call(String line) throws Exception {
//                String[] split = line.split("\\t");
//                String kaoshiId = split[0];
//                String kaoshishijue = split[1];
//                String tiihao = split[5];
//                String score = split[6];
//                String jiexi = split[4];
//
//                // 知识点
//                JSONObject jiexiObj = JSONObject.parseObject(jiexi);
//                String zhishi = jiexiObj.getString("zhishi");
//                zhishi = zhishi.replace("\\\"", "");
//
//                String[] sb = zhishi.split(" ");
//
//
//                List<Tuple9> tupleList = new ArrayList<>();
//                for (String s : sb) {
//
//                    Tuple9<String, String, String, String, String, String, String, String, String> tuple = new Tuple9<>(kaoshiId, kaoshishijue, tiihao, "主观题", score, s, "", jiexi, "");
//
//
//                    tupleList.add(tuple);
//                }
//
//                return tupleList.iterator();
//            }
//        });
//
//
//        rddResult.saveAsTextFile("datas/exam/主观题1_result");
//
//
//        javaSparkConf.stop();
    }





}
